Pairwise combinations from a set of elements have various applications in probability and statistics. For example, the problem of determining the chance of randomly picking a specific pair of items may be analyzed by performing all pairwise combinations of possible items. This is famously demonstrated in the probability of rolling a specific value such as “snake eyes”, or a pair of ones, using two, six-sided dice. The probability is one out of thirty-six which is very low and requires a “lucky” roll since a pair of ones is just one outcome out of all possible (6×6=36) pairs. Each of the thirty-six pairs can be identified by the Cartesian product of two identical sets, {1,2,3,4,5,6}, yielding a new set of pairs, (1,1),(1,2),(1,3), and so on. The Cartesian product can be described in a step-wise fashion where the first element of the first set is paired with all elements of the second set, and this is then repeated for each of the remaining elements of the first set. To exclude permutations, where (y,x) is considered a duplicate of (x,y), the aforementioned steps can be modified so that each element of the first set skips over those elements whose values are less than itself. This can be further extended to ignore pairs of equal value, e.g. (x,x), resulting in only unique, pairwise combinations. For a given set of n elements the total number of unique, pairwise combinations is calculated by the binomial coefficient,
      (                            n                                      2                      )    =                    n        !                              2          !                ⁢                              (                          n              -              2                        )                    !                      =                  n        ⁡                  (                      n            -            1                    )                    2      
Thus, for a set of six elements there are a total of 6*5/2=15 unique pairs.
Constructing unique pairs is also an operation of many graph algorithms such as enumerating triangles and calculating all-pairs, vertex similarity. Given a graph G=(V,E) where V is the vertex set and E is the edge set, then let n=|V| and m=|E| be the number of vertices and edges, respectively. A vertex is a neighbor of another vertex if both are connected by an edge. A procedure to identify all triangles in a graph begins first by constructing all unique pairs of neighbors for each vertex, and then each such pair is tested to be neighbors themselves which would identify a triangle between that pair and the vertex from which the pair were first acquired.